package com.bdqn.staffmanagementsystem.controller;

import com.bdqn.staffmanagementsystem.service.EmployeeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/Employee")
public class EmployeeController {
    @Resource
    private EmployeeService employeeService;

    @RequestMapping("/formsignin")
    public String Formsignin(Model model, String username, String email, HttpServletRequest request){
        int i = employeeService.Login(username, email);
        if (i>0){
            System.out.println(i);
            request.getSession().setAttribute("LoginUser",i+"");
            return "/dashboard";
        }else {
            model.addAttribute("LoginStatus","登录失败，请确保用户名和email输入正确");
            return "/index";
        }
    }
}
